import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Vector;


public class Compiler {
		static ArrayList<String> parsetree = new ArrayList<String>();
		static String variableuse = "";
		static String variablename = "";
		static String valueofvalue = "";
		static boolean pause = false;
		static String filename;
		static String text = "";
		static int CurrentPosition = 0;
        static String token = "";
		static StringBuilder fulltext = new StringBuilder();
        static MyLexicalAnalyzer lexer = new MyLexicalAnalyzer();	
        static MySyntaxAnalyzer syntax = new MySyntaxAnalyzer();
		
        public static void main(String[] args) throws FileNotFoundException, NullPointerException, IOException, CompilerException {
        
           //MyLexicalAnalyzer lexer = new MyLexicalAnalyzer();	
           //MySyntaxAnalyzer syntax = new MySyntaxAnalyzer();
        	
        	filename = args[0];
        	String extension = filename.substring(filename.lastIndexOf(".") + 1, filename.length());

    		String mkd = "mkd";
    		if (!mkd.equals(extension)) {
    		    throw new IOException("Not a .mkd extension!");
    		}
    		else {
        	
        	BufferedReader buff = null;
        	try {
        		String currentLine;
        		buff = new BufferedReader(new FileReader(filename));
        		while ((currentLine = buff.readLine())!= null){
        			//System.out.println(currentLine);
        			fulltext.append(currentLine);
        		}	
        	}
        	catch (IOException e) {
    			e.printStackTrace();
    		}
            MyLexicalAnalyzer analyzer = new MyLexicalAnalyzer();
            syntax.document();
            MySemanticAnalyzer semantic = new MySemanticAnalyzer();
            semantic.html();
            
            
				// TODO Auto-generated catch block
			}
                
                
                //1. check to make sure args
                //2. check to make sure the file has an mkd extension
                //3. inits
                //4. call the lexical analyzer to get the first token set
                //5. call the start state of the parser i.e. document()
                
                //... lexer and parser do their thing
                
                //6. call the symantic analyzer 
                //7. write the output file
                //8. clean up
        }
}
